<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>登录</title>
    <script src="../WF/Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../WF/Scripts/bootstrap/js/jquery.min.js"></script>
    <script src="../WF/Scripts/config.js" type="text/javascript"></script>
    <script src="../WF/Comm/Gener.js" type="text/javascript"></script>
    <script src="../WF/Scripts/bootstrap/js/bootstrap.min.js"></script>
    <script src="layer/layer.js"></script>
    <link rel="stylesheet" href="css/reset.css">
    <link rel="stylesheet" href="css/login.css">
    <script type="text/javascript">
        document.onkeydown = function (e) {
            e = e || window.event;
            if (e.keyCode == 13) {
                Login();
                return false;
            }
        }
      

        //初始化页面函数.....
        $(function () {
            $('#psw_change').click(function (event) {
                debugger
                var event = event || window.event;
                event.stopPropagation();
                var $this = $(this);
                $this.toggleClass('psw_show');
                //如果当前隐藏  变显示
                if ($this.hasClass('psw_show')) {
                    $this.css({
                        'background': 'url(/PM/image/psw1.png) no-repeat center center'
                    });
                    $this.prev().attr('type', 'text');
                } else {
                    $this.css(
                        'background', 'url(/PM/image/psw0.png) no-repeat center center'
                    );
                    $this.prev().attr('type', 'password');
                }
            });

            if (! +[1,]) {
                //  alert("这是ie浏览器，您只能使用sliverlight版本浏览器。");
                // window.location.href = '../XAP/Designer.htm';
                // return;
            }

            //$("#Msg").html("<img src='../Img/loading.gif' /><font color=blue>ccbpm 正在为登录/自动升级做准备.</font>");

            //document.getElementById("Btn_Login").disabled = 'disabled';
            //执行更新检查..
            var doType = GetQueryString("DoType");
            var href = window.location.href;
            var urlParam = href.substring(href.indexOf('?') + 1, href.length);
            urlParam = urlParam.replace('&DoType=', '&DoTypeDel=xx');

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Portal");
            if (doType != null && doType != undefined && doType != "")
                handler.AddPara("LoginType", doType);
            handler.AddUrlData(urlParam);
            data = handler.DoMethodReturnString("Login_Init");

            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }
            if (data.indexOf("Install") != -1) {
                var data = data.replace('url@', '');
                window.location.href = data;
                return;
            }
            data = JSON.parse(data);

            //调用公共类库的方法:执行批量主表赋值
            GenerFullAllCtrlsVal(data);

            document.title = data.SysName;

            var userNo = $("#username").val();
            if (userNo == "")
                $("#password").val("");

            $("body").keydown(function () {
                if (event.keyCode == 13) {
                    event.cancelBubble = true;
                    event.returnValue = false;
                    Login();
                }
            });

            handler = new HttpHandler("BP.WF.HttpHandler.WF_Portal");

            var data = handler.DoMethodReturnString("Login_VerifyState");

            if (data.indexOf('err@') == 0) {
                //document.getElementById("verifycode").style.marginLeft = "10px";
                document.getElementById("verifycode").src = data.split('@')[1];
            }
        });
        function createCode() {
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Portal");

            $("#verifycode").attr('src', handler.DoMethodReturnString("Login_VerifyCode"));
        }
        function LoginText() {
            window.location.href = "Default.htm";
        }

        //执行后台登录.
        function Login() {
            //$("#Msg").html("<font> ccbpm 正在登录流程&表单引擎设计器,请稍候... </font>");
            var loading = layer.load(1, { shade: [0.1, '#fff'] });
            var handler = new HttpHandler("BP.PM.AppHandler");
            layer.close(loading);
            var userNo = $("#username").val();
            var pass = $("#password").val();

            if (userNo == "" || pass == "") {
                layer.msg("<font>请输入用户名，密码.</font>");
                return;
            }
            //判断验证码是否正确.
            //var node = $("#validate");
            //if (node.is(':visible') && $("#inputCode").val() == '') {
            //    layer.msg("<font color=red>请输入验证码</font>");
            //    return;
            //}
            //handler.AddPara("VerifyCode", $("#inputCode").val());
            handler.AddPara("TB_No", userNo);
            handler.AddPara("TB_PW", pass);

            var data = handler.DoMethodReturnString("Login_Submit");
            

            if (data.indexOf('err@') == 0) {
                layer.msg("<font color=red>" + data.replace("err@", "") + "</font>");
                //$("#validate").show();
                //$("#verifycode").attr('src', handler.DoMethodReturnString("Login_VerifyCode"));
                return;
            }

            if (data.indexOf("Install") != -1) {
                var data = data.replace('url@', '');
                window.location.href = data;
                return;
            }
            if (data.indexOf('url@') == 0) {
                var data = data.replace('url@', '');
                data = data.replace(/Default.htm/, "index.html");
                SetHref(data);
                return;
            }

            layer.close(index);
            alert(data);
        }
    </script>
</head>
<body class="login_bg">
    <div class="login">
        <h1 class="title">项目管理平台</h1>
        <div class="search-box">
            <div class="formInput">
                <h6 class="form-title">欢迎登录</h6>
                <div class="form-box">
                    <div class="username">
                        <label for="username"><img src="image/yhm.png"></label>
                        <input id="username" class="login-ipt" type="text" placeholder="用户名" />
                    </div>
                    <div class="pwd">
                        <label for="password">
                            <img src="./image/mm.png" />
                        </label>
                        <input id="password" class="login-ipt" type="password" placeholder="密码">
                        <span id="psw_change"></span>
                    </div>
                    <!--<div class="verifycode" id="validate">
                        <label for="password">
                            <img src="./image/mm.png" />
                        </label>
                        <input id="inputCode" type="text" placeholder="验证码">
                        <img id="verifycode" src="" onclick="createCode();" />-->
                    <!--<a href="javascript:void(0)" style="margin-left: 10px;" onclick="createCode()">看不清?</a>-->
                    <!--</div>-->
                    <div class="jzmm">
                        <div>
                            <input type="checkbox" id="remember_password" />
                            <label for="remember_password" style="vertical-align:bottom !important;">记住密码</label>
                        </div>
                        <!--<div style="float: right;cursor: pointer;">忘记密码</div>-->
                    </div>
                    <div class="btn" onclick="Login();">登&nbsp;&nbsp;录</div>
                </div>
            </div>
            <!-- <h6 class="tip">建议在版本为60以上的谷歌浏览器上使用本系统</h6> -->
        </div>
    </div>
</body>
</html>